package com.ssy.lingxi.member.merchant.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.ssy.lingxi.member.merchant.handler.converter.JpaJsonToFileListConverter;
import com.ssy.lingxi.member.merchant.model.bo.FileBO;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 会员考评项目
 * @author yzc
 * @version 2.0.0
 * @date 2021/5/17
 */
@Entity
@Table(schema = "public", name = "ms_mc_member_appraisal_item")
public class MemberAppraisalItemDO implements Serializable {
    private static final long serialVersionUID = 5159126854814834425L;

    /**
     * 主键id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "member_appraisal_item_seq")
    @SequenceGenerator(sequenceName = "ms_mc_member_appraisal_item_seq", name = "member_appraisal_item_seq", allocationSize = 1)
    private Long id;

    /**
     * 多对一双向关联会员考评
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "appraisal_id", referencedColumnName = "id")
    private MemberAppraisalDO appraisal;

    /**
     * 项目类型
     * 0-自定义
     * 1-供货及时率, 供货及时率得分 = 统计期间及时到货的采购订单数 /统计期间的所有到货采购订单数 * 100
     * 2-供货合格率, 供货合格率得分 = 统计期间合格到货订单数/统计期间所有到货采购订单数 * 100
     */
    @Column
    private Integer type;

    /**
     * 项目名称
     */
    @Column
    private String name;

    /**
     * 项目内容
     */
    @Column
    private String content;

    /**
     * 状态 0-待打分 1-已打分
     */
    @Column
    private Integer status;

    /**
     * 多对一单向关联下级会员用户(考评人员)
     */
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private MemberUserDO byUser;

    /**
     * 发送考评人打分  0-否 1-是
     */
    @Column
    private Integer sendAppraisal;

    /**
     * 评分权重
     */
    @Column
    private Integer scoreWeight;

    /**
     * 考评计分
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal grade;

    /**
     * 得分
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal score;

    /**
     * 考评模板
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> templates;

    /**
     * 考评报告
     */
    @Convert(converter = JpaJsonToFileListConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<FileBO> reports;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public MemberAppraisalDO getAppraisal() {
        return appraisal;
    }

    public void setAppraisal(MemberAppraisalDO appraisal) {
        this.appraisal = appraisal;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public MemberUserDO getByUser() {
        return byUser;
    }

    public void setByUser(MemberUserDO byUser) {
        this.byUser = byUser;
    }

    public Integer getSendAppraisal() {
        return sendAppraisal;
    }

    public void setSendAppraisal(Integer sendAppraisal) {
        this.sendAppraisal = sendAppraisal;
    }

    public Integer getScoreWeight() {
        return scoreWeight;
    }

    public void setScoreWeight(Integer scoreWeight) {
        this.scoreWeight = scoreWeight;
    }

    public BigDecimal getGrade() {
        return grade;
    }

    public void setGrade(BigDecimal grade) {
        this.grade = grade;
    }

    public BigDecimal getScore() {
        return score;
    }

    public void setScore(BigDecimal score) {
        this.score = score;
    }

    public List<FileBO> getTemplates() {
        return templates;
    }

    public void setTemplates(List<FileBO> templates) {
        this.templates = templates;
    }

    public List<FileBO> getReports() {
        return reports;
    }

    public void setReports(List<FileBO> reports) {
        this.reports = reports;
    }
}
